<template>
	<el-breadcrumb style="padding: 30px;">
		<el-breadcrumb-item>首页</el-breadcrumb-item>
		<el-breadcrumb-item>小程序数据</el-breadcrumb-item>
		<el-breadcrumb-item>商品兑换管理</el-breadcrumb-item>
	</el-breadcrumb>
	<div>
		<el-table v-show="cjtype === null" class="mb20" :data="tableData" border style="width: 100%">
			<el-table-column prop="num" label="序号"></el-table-column>
			<el-table-column prop="name" label="姓名" />
			<el-table-column prop="numbers" label="手机号码" width="120" />
			<el-table-column prop="title" label="兑换商品" />
			<el-table-column prop="address" label="用户预留地址" />
			<el-table-column prop="kuaidi" label="快递单号" />
			<el-table-column prop="fhzt" label="发货状态">
				<template #default="scope">
					<el-select v-model="scope.row.fhzt" placeholder="请选择发货状态" size="large">
						<el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value" />
					</el-select>
				</template>
			</el-table-column>

			<el-table-column label="操作" width="180">
				<template #default="scope">
					<!-- <el-button size="mini" type="danger" @click="removeModal({row:scope.row,index:scope.$index})">删除
						</el-button> -->
					<el-button size="mini" type="primary" @click="editmsg(scope.row.id, scope.row.kuaidi)">修改快递单号
					</el-button>
				</template>
			</el-table-column>




		</el-table>

		<el-dialog v-model="msgshow" title="快递单号">
			<el-form :inline="true" class="demo-form-inline">
				<el-form-item label="">
					<el-input v-model="kuaidi" autocomplete="off"></el-input>
				</el-form-item>


				<el-form-item>
					<el-button @click="msgsubmit" type="primary">确定</el-button>
				</el-form-item>
			</el-form>
		</el-dialog>
		<!-- <el-pagination class="mt20" v-model:currentPage="page" @current-change="getData" :page-size="10" background
			layout="prev, pager, next" :total="total">
		</el-pagination> -->
	</div>
</template>

<script>
import dayjs from "dayjs";
import {
	ElMessageBox,
	ElMessage
} from "element-plus";
export default {
	components: {},
	watch: {


	},
	data() {
		return {
			options: [{
				value: '0',
				label: '未发货'
			}, {
				value: '1',
				label: '已发货'
			}, {
				value: '2',
				label: '已收货'
			}],
			cjtype: null,
			jifen: null,
			msgshow: false,
			typename: {
				"s7": 's7',
				"ilike": "i-like",
				"ionex": "i-onex",
				"ionexs": "i-onexP"

			},
			dayjs,
			dataf: 0,
			token: 0,
			rankshows: false,
			rankshow: false,
			kuaidi: "",
			status: {
				0: "审核中",
				1: "正常",
				2: "隐藏",
				3: "不通过",
			},
			type: null,
			sjstatus: null,
			wdhx: "", //   已核销 
			ishexiao: "", // 已试驾
			fk: "", //已反馈
			viewarr: [],
			modalStatewins: false,
			hdqtxmname: "", //     名称
			hdjifen: "", //   加积分
			numbers: "", //  手机
			modalStatewin: false,
			qrcode: null,
			modalStatecode: false,
			vtimes: ["", ""],
			formLabelWidth: "120px",
			times: "",
			form: {
				is_show: "1",
				images: "",
				content: "",
				jifen: "",
				starttime: "",
				endtime: "",
				title: "",
				is_hot: "0",
				author: "0",
			},
			tableData: [],
			rules: {
				title: [{
					required: true,
					message: "请填写标题",
					trigger: "blur",
				},],
				jifen: [{
					required: true,
					message: "请填写积分",
					trigger: "blur",
				},],
				content: [{
					required: true,
					message: "请填写内容",
					trigger: "blur",
				},],
				starttime: [{
					required: true,
					message: "请选择时间",
					trigger: "change",
				},],
			},
			pid: [],
			bqlist: [],
			viewdata: "",
		};
	},
	async mounted() {
		// await this.$http.post("index.php/index/Admins/bqlist").then((data) => {
		//   this.bqlist = data;
		// });
		await this.getData();
	},
	methods: {
		views(data) {
			console.log(data);
			this.viewdata = data.row;
			this.rankshows = true;
		},
		getDatas() {
			this.page = 1;
			this.getData()
		},
		msgsubmit() {
			this.$http
				.post("/index.php/index/jf/dhupdate", {
					kuaidi: this.kuaidi,
					id: this.id
				}).then(() => {
					this.kuaidi = "";
					ElMessage({
						message: "编辑成功",
						type: "success",
					});
					this.msgshow = false;
					this.getData();
				})
		},
		getData() {
			this.$http
				.post("/index.php/index/jf/dhlist", {})
				.then((datas) => {
					// this.dataf = datas.data.total;
					// this.token = datas.data.totalz;
					// this.total = datas.data.total;
					datas.data.forEach((t, i) => {

						t.num = (this.page - 1) * 10 + 1 + i
					})
					this.tableData = datas.data;
					// if(datas.length>0){
					// var data = datas[0];
					// this.tableData = data;
					// this.total = datas[1];
					// }else{
					//   this.tableData = [];
					//    this.total = 0;
					// }

				});
		},
		// submit(ref) {
		// 	console.log(this.$refs);
		// 	this.doRules(this.$refs[ref]).then(() => {
		// 		if (this.id) this.form.id = this.id;

		// 		this.$http
		// 			.post(
		// 				this.id ?
		// 				"/index.php/index/Userinfo/hdedittj" :
		// 				"/index.php/index/Userinfo/hdadd",
		// 				this.form
		// 			)
		// 			.then((data) => {
		// 				console.log(data);
		// 				this.modalState = false;
		// 				ElMessage({
		// 					message: this.id ? "编辑成功" : "新增成功",
		// 					type: "success",
		// 				});
		// 				this.getData();
		// 			});
		// 	});
		// },
		editmsg(id, kd) {
			this.kuaidi = kd;
			this.id = id;
			this.msgshow = true;
		},
		remove(data) {
			this.$http
				.post("/index.php/index/goodses/sjxcxdel", {
					id: data.row.id
				})
				.then((data) => {
					ElMessage({
						message: "删除成功",
						type: "success",
					});
					this.getData();
				});
		},
		handleAvatarSuccess(file) {
			this.form.image = file.data;
		},
	},
};
</script>
